package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.net.domain.BusiMtnChannelCrossListVo;
import com.ruoyi.net.domain.NetElement;
import com.ruoyi.net.mapper.NetElementMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.net.mapper.BusiMtnChannelCrossMapper;
import com.ruoyi.net.domain.BusiMtnChannelCross;
import com.ruoyi.net.service.IBusiMtnChannelCrossService;

/**
 * 业务-MTN Channel crossService业务层处理
 * 
 * @author tony
 * @date 2024-12-28
 */
@Service
public class BusiMtnChannelCrossServiceImpl implements IBusiMtnChannelCrossService 
{
    @Autowired
    private BusiMtnChannelCrossMapper busiMtnChannelCrossMapper;
    @Autowired
    private NetElementMapper netElementMapper;

    /**
     * 查询业务-MTN Channel cross
     * 
     * @param id 业务-MTN Channel cross主键
     * @return 业务-MTN Channel cross
     */
    @Override
    public BusiMtnChannelCross selectBusiMtnChannelCrossById(String id)
    {
        return busiMtnChannelCrossMapper.selectBusiMtnChannelCrossById(id);
    }

    /**
     * 查询业务-MTN Channel cross列表
     * 
     * @param busiMtnChannelCross 业务-MTN Channel cross
     * @return 业务-MTN Channel cross
     */
    @Override
    public List<BusiMtnChannelCrossListVo> selectBusiMtnChannelCrossList(BusiMtnChannelCross busiMtnChannelCross)
    {

        List<BusiMtnChannelCrossListVo> busiMtnChannelCrossListVos = busiMtnChannelCrossMapper.selectBusiMtnChannelCrossList(busiMtnChannelCross);
        if (busiMtnChannelCross.getElementId()!=null){
            for (BusiMtnChannelCrossListVo busiMtnChannelCrossListVo : busiMtnChannelCrossListVos) {
                NetElement netElement = netElementMapper.selectNetElementById(busiMtnChannelCross.getElementId());
                busiMtnChannelCrossListVo.setElementName(netElement.getElementName());
            }
        }
        return busiMtnChannelCrossListVos;
    }

    /**
     * 新增业务-MTN Channel cross
     * 
     * @param busiMtnChannelCross 业务-MTN Channel cross
     * @return 结果
     */
    @Override
    public int insertBusiMtnChannelCross(BusiMtnChannelCross busiMtnChannelCross)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(busiMtnChannelCross.getId())) {
            busiMtnChannelCross.setId(uuid);
        }
        busiMtnChannelCross.setCreateBy(SecurityUtils.getUsername());
        busiMtnChannelCross.setCreateTime(DateUtils.getNowDate());
        busiMtnChannelCross.setUpdateBy(SecurityUtils.getUsername());
        busiMtnChannelCross.setUpdateTime(DateUtils.getNowDate());
        return busiMtnChannelCrossMapper.insertBusiMtnChannelCross(busiMtnChannelCross);
    }

    /**
     * 修改业务-MTN Channel cross
     * 
     * @param busiMtnChannelCross 业务-MTN Channel cross
     * @return 结果
     */
    @Override
    public int updateBusiMtnChannelCross(BusiMtnChannelCross busiMtnChannelCross)
    {
        busiMtnChannelCross.setUpdateBy(SecurityUtils.getUsername());
        busiMtnChannelCross.setUpdateTime(DateUtils.getNowDate());
        return busiMtnChannelCrossMapper.updateBusiMtnChannelCross(busiMtnChannelCross);
    }

    /**
     * 批量删除业务-MTN Channel cross
     * 
     * @param ids 需要删除的业务-MTN Channel cross主键
     * @return 结果
     */
    @Override
    public int deleteBusiMtnChannelCrossByIds(String[] ids)
    {
        return busiMtnChannelCrossMapper.deleteBusiMtnChannelCrossByIds(ids);
    }

    /**
     * 删除业务-MTN Channel cross信息
     * 
     * @param id 业务-MTN Channel cross主键
     * @return 结果
     */
    @Override
    public int deleteBusiMtnChannelCrossById(String id)
    {
        return busiMtnChannelCrossMapper.deleteBusiMtnChannelCrossById(id);
    }

    @Override
    public int updateBusiMtnChannelCrossStatusByParam(BusiMtnChannelCross busiMtnChannelCross) {
        return busiMtnChannelCrossMapper.updateBusiMtnChannelCrossStatusByParam(busiMtnChannelCross);
    }
}
